package com.xinlong.controller;

import com.xinlong.service.StatisticsService;
import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.Map;
import java.util.List;

@Controller
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsServiceImpl;


    @RequestMapping("/popular.do")
    public ModelAndView popular(){
        ModelAndView modelAndView = new ModelAndView("popular");
        return modelAndView;
    }


    @RequestMapping("/turnover.do")
    public ModelAndView turnover(){
        ModelAndView modelAndView = new ModelAndView("turnover");
        return modelAndView;
    }

    @RequestMapping("/portrait.do")
    public ModelAndView portrait(){
        ModelAndView modelAndView = new ModelAndView("portrait");
        return modelAndView;
    }




    @RequestMapping("/year.do")
    @ResponseBody
    public Map<String,Object> year(){
        return statisticsServiceImpl.yearTurnover();
    }

    @RequestMapping("/month.do")
    @ResponseBody
    public Map<String,Object> month(){
        return statisticsServiceImpl.monthTurnover();
    }



    @RequestMapping("/sex.do")
    @ResponseBody
    public List<Map<String,Object>> sex(){
        return statisticsServiceImpl.sexStatistics();
    }

    @RequestMapping("/occupation.do")
    @ResponseBody
    public List<Map<String,Object>> occupation(){
        return statisticsServiceImpl.occupationStatistics();
    }

    @RequestMapping("/age.do")
    @ResponseBody
    public List<Map<String,Object>> age(){
        return statisticsServiceImpl.ageStatistics();
    }

    @RequestMapping("/city.do")
    @ResponseBody
    public Map<String,Object> city(){
        return statisticsServiceImpl.popular();
    }

}
